Calculation of trigonometric functions in an integrated circuit device

ABSTRACT

Circuitry for computing a tangent function of an input value includes first look-up table circuitry that stores pre-calculated tangent values of a limited number of sample values, circuitry for inputting bits of the input value of most significance as inputs to the first look-up table circuitry to look up one of the pre-calculated tangent values as a first intermediate tangent value, circuitry for calculating a second intermediate tangent value from one or more ranges of remaining bits of the input value, and circuitry for combining the first intermediate tangent value and the second intermediate tangent value to yield the tangent function of the input value.

CROSS REFERENCE TO RELATED APPLICATION

This is a continuation-in-part of copending, commonly-assigned U.S.patent application Ser. No. 12/823,539, filed Jun. 25, 2010, which ishereby incorporated by reference herein in its entirety.

FIELD OF THE INVENTION

This invention relates to calculating trigonometric functions inintegrated circuit devices, and particularly in programmable integratedcircuit devices such as programmable logic devices (PLDs).

BACKGROUND OF THE INVENTION

Trigonometric functions are generally defined for the relatively smallangular range of 0-360°, or 0-2π radians. For angular values above 2π,the values of the trigonometric functions repeat. Indeed, one couldrestrict the range to 0-π/2, because various trigonometric identitiescan be used to derive values for trigonometric functions of any anglebetween π/2 and 2π from trigonometric functions of angles between 0 andπ/2.

One method that may be used in integrated circuit devices forcalculating trigonometric functions is the CORDIC algorithm, which usesthe following three recurrence equations:

x _(n+1) =x _(n) −d _(n) y _(n)2^(−n)

y _(n+1) =y _(n) +d _(n) x _(n)2^(−n)

z _(n+1) =z _(n) −d _(n) tan⁻¹(2^(−n))

For example, to calculate a sine or cosine of an input, the x value isinitialized to “1”, the y value is initialized to “0”, and the Z valueis initialized to the angle required. Z is then rotated towards zero,which determines the sign of dn, which is ±1—if zn is positive, then sois dn, as the goal is to bring z closer to 0; if zn is negative, then sois dn, for the same reason. x and y represent the x and y components ofa unit vector; as z rotates, so does that vector, and when z has reachedits final rotation to 0, the values of x and y will have converged tothe cosine and sine, respectively, of the input angle.

To account for stretching of the unit vector during rotation, a scalingfactor is applied to the initial value of x. The scaling factor is:

${\prod\limits_{n = 0}^{\infty}\; \sqrt{1 + 2^{{- 2}n}}} = {1.64676025812106564\mspace{20mu} \ldots}$

The initial x is therefore be set to 1/1.64677 . . . =0.607252935 . . ..

However, CORDIC may become inaccurate as the inputs become small. Forexample, the actual value of sin(θ) approaches θ as θ approaches 0 (andtherefore sin(θ) approaches 0), and the actual value of cos(θ)approaches 1 as θ approaches 0. However, the magnitude of the errorbetween the calculated and actual values increases as e decreases.

Moreover, while CORDIC on initial consideration appears to be easilyimplemented in integrated circuit devices such as FPGAs, closer analysisshows inefficiencies, at least in part because of multiple, deeparithmetic structures, with each level containing a wide adder. CommonFPGA architectures may have 4-6 input functions, followed by a dedicatedripple carry adder, followed by a register. When used for calculatingfloating point functions, such as the case of single precision sine orcosine functions, the number of hardware resources required to generatean accurate result for smaller input values can become large. Doubleprecision functions can increase the required resources even further.

SUMMARY OF THE INVENTION

According to embodiments of the present invention, differenttrigonometric functions may be computed using various modifiedimplementations that are based on different trigonometric identitiesthat can be applied.

For sine and cosine functions, a modified CORDIC implementation changessmall input angles to larger angles for which the CORDIC results aremore accurate. This may be done by using π/2−θ instead of θ for small θ(e.g., for θ<π/4). As discussed above, CORDIC accuracy suffers forsmaller angles, but a standard CORDIC implementation may be used forlarger angles. A multiplexer can select between the input value θ andthe output of a subtractor whose subtrahend and minuend inputs are,respectively, π/2 and the input value θ. A comparison of the input θ toa threshold can be used to control the multiplexer to make theselection. Both sine and cosine are computed by the x and y datapaths ofthe CORDIC implementation and the desired output path can be selectedusing another multiplexer, which may be controlled by the samecomparison output as the input multiplexer. When π/2−θ has been used asthe input, the identities cos(θ)=sin(π/2−θ) and sin(θ)=cos(π/2−θ) can beused to derive the desired result.

For the tangent function, the input angle can be broken up into the sumof different ranges of bits of the input angle, using trigonometricidentities for the tangent of a sum of angles. Because some of thecomponent ranges will be small, the identities will be simplifiedrelative to those component ranges. The identities can be implemented inappropriate circuitry, as either a single-precision function or adouble-precision function.

For the inverse tangent (i.e., arctan or tan⁻¹) function, the problem isthat the potential input range is between negative infinity and positiveinfinity (unlike, e.g., inverse sine or inverse cosine, where thepotential input range is between −1 and +1). In accordance with theinvention, trigonometric identities involving the inverse tangentfunction can be used to break up the input into different ranges, withthe most complicated portion of the identity having a contribution belowthe least significant bit of the result, so that it can be ignored. Theidentities can be implemented in appropriate circuitry.

For inverse cosine (i.e., arccos or cos⁻¹), the following identity maybe used:

${\arccos = {2{\arctan \left( \frac{\sqrt{1 - x^{2}}}{1 + x} \right)}}},$

which may be reduced to:

$\arccos = {2{{\arctan \left( \frac{1 - x}{\sqrt{1 - x^{2}}} \right)}.}}$

The inverse tangent portion may be calculated as discussed above,simplified because the input range for inverse cosine is limited tobetween 0 and 1. Known techniques may be used to calculate the inversesquare root. For inverse sine (i.e., arcsin or sin⁻¹), which also has aninput range limited to between 0 and 1, the inverse cosine can becalculated and then subtracted from π/2, based on the identityarcsin(x)=π/2-arccos(x).

Therefore, in accordance with the present invention there is providedcircuitry for computing a tangent function of an input value. Thatcircuitry includes first look-up table circuitry that storespre-calculated tangent values of a limited number of sample values,circuitry for inputting bits of the input value of most significance asinputs to the first look-up table circuitry to look up one of thepre-calculated tangent values as a first intermediate tangent value,circuitry for calculating a second intermediate tangent value from oneor more ranges of remaining bits of the input value, and circuitry forcombining the first intermediate tangent value and the secondintermediate tangent value to yield the tangent function of the inputvalue.

A corresponding method for configuring an integrated circuit device assuch circuitry is also provided. Further, a machine-readable datastorage medium encoded with instructions for performing the method ofconfiguring an integrated circuit device is provided.

BRIEF DESCRIPTION OF THE DRAWINGS

Further features of the invention, its nature and various advantageswill be apparent upon consideration of the following detaileddescription, taken in conjunction with the accompanying drawings, inwhich like reference characters refer to like parts throughout, and inwhich:

FIG. 1 shows a first embodiment of a CORDIC implementation forcalculating sine and/or cosine in accordance with the present invention;

FIG. 2 shows a second embodiment of a CORDIC implementation forcalculating sine and/or cosine in accordance with the present invention;

FIG. 3 shows a third embodiment of a CORDIC implementation forcalculating sine and/or cosine in accordance with the present invention;

FIG. 4 shows a fourth embodiment of a CORDIC implementation forcalculating sine and/or cosine in accordance with the present invention;

FIG. 5 shows an embodiment of an implementation for calculating tangentin accordance with the present invention;

FIG. 6 shows an embodiment of a portion of another implementation forcalculating tangent in accordance with the present invention;

FIG. 7 shows a first range of the inverse tangent function;

FIG. 8 shows a second range of the inverse tangent function;

FIG. 9 shows a third range of the inverse tangent function;

FIG. 10 shows an embodiment of an implementation for calculating inversetangent in accordance with the present invention;

FIG. 11 shows a first portion of an embodiment of an implementation forcalculating inverse cosine and/or inverse sine in accordance with thepresent invention;

FIG. 12 shows a second portion of an embodiment of an implementation forcalculating inverse cosine and/or inverse sine in accordance with thepresent invention;

FIG. 13 is a cross-sectional view of a magnetic data storage mediumencoded with a set of machine-executable instructions for performing themethod according to the present invention;

FIG. 14 is a cross-sectional view of an optically readable data storagemedium encoded with a set of machine executable instructions forperforming the method according to the present invention; and

FIG. 15 is a simplified block diagram of an illustrative systememploying a programmable logic device incorporating the presentinvention.

DETAILED DESCRIPTION OF THE INVENTION

As discussed above, in a standard CORDIC implementation:

x _(n+1) =x _(n) −d _(n) y _(n)2^(−n)

y _(n+1) =y _(n) +d _(n) x _(n)2^(−n)

z _(n+1) =z _(n) −d _(n) tan⁻¹(2^(−n))

As can be seen from these equations, at the first level (for n=0):

x ₁ =x ₀ −y ₀

y ₁ =y ₀ +x ₀

z ₁ =z ₀−tan⁻¹(1)

Similarly, at the second level (for n=1):

x ₂ =x ₁ −d ₁(y ₁/2)

y ₂ =y ₁ +d ₁(x ₁/2)

z ₂ =z ₁ −d ₁ tan⁻¹(0.5)

It will be understood that this continues for additional n until znconverges to 0, or as close to 0 as required by a particularimplementation. However, as discussed above, the accuracy of a CORDICimplementation decreases as the input angle becomes small.

A logical structure 100 of a first embodiment according to the presentinvention for implementing CORDIC for sine or cosine is shown in FIG. 1.Structure 100 may be implemented as circuitry. Structure 100 is builtaround a CORDIC engine 101 which may be any suitable CORDIC engine,including that described in copending, commonly-assigned U.S. patentapplication Ser. No. 12/722,683, filed Mar. 12, 2010, which is herebyincorporated by reference herein in its entirety. CORDIC engine 101provides an x output 111 which generally represents the cosine of theinput, as well as a y output 112 which generally represents the sine ofthe input.

Input multiplexer 102 selects either the input variable 103, ordifference 104 between π/2 and input variable 103. The control signal105 for input multiplexer 102 result from a comparison 106 that whichindicate(s) whether input variable 103 (θ) is greater than π/4 or lessthan π/4 (or whatever other threshold may be selected). Because inputvariable 103 preferably is expressed as a fraction (impliedly multipliedby π/2), the comparison may be performed simply by examining one or moreof the most significant bits of input variable 103. Alternatively, amore complex comparison may be made.

In any event, the value passed to CORDIC engine is either θ or π/2−θ,depending on whether θ is greater than (or equal to) or less than π/4.

The same control signal 105 that determines the input to CORDIC engine101 helps to determine which output 111, 112 is selected by outputmultiplexer 107. Specifically, cos(θ)=sin(π/2−θ) and sin(θ)=cos(π/2−θ).Additional input 115 may be provided that represents whether the desiredoutput is sine or cosine, and that input is combined at 125 with input105, to provide a control signal 135, so that if input variable 103 (θ)was used as the CORDIC input directly, then output 111 is selected ifthe desired function is cosine and output 112 is selected if the desiredfunction is sine. But if difference 104 (π/2−θ) was used as the CORDICinput, then output 112 is selected if the desired function is cosine andoutput 111 is selected if the desired function is sine.

Known techniques for speeding up CORDIC calculations can be used. Forexample, once about halfway through the CORDIC calculation of a sinevalue, the final value of y can be approximated by multiplying thethen-current value of x by the then-current value of z, and thensubtracting that product from the then-current value of y. Similarly,for cosine, the final value of x can be approximated by multiplying thethen-current value of y by the then-current value of z and adding thatproduct to the then-current value of x. This may be referred to as“terminated CORDIC.” FIG. 2 shows a modified CORDIC structure 200 thatimplements terminated CORDIC in accordance with an embodiment of theinvention. Structure 200 may be implemented as circuitry.

The input stage of structure 200 is identical to that of structure 100,including input multiplexer 102, input variable 103, difference 104,comparison circuit 106 and control signal 105. CORDIC engine 201 may bethe same as CORDIC engine 101, except that the z datapath is used as anoutput 211, in addition to outputs 111, 121.

However, the output stage of structure 200 differs from the output stageof structure 100. Instead of one output multiplexer 106, there is afirst output multiplexer 206 controlled by signal 135 and a secondoutput multiplexer 216 controlled by the inverse of signal 135. Forcosine, this arrangement provides x directly to adder/subtractor 208,and provides y and z to multiplier 207, which provides its output toadder/subtractor 208. For sine, this arrangement provides y directly toadder/subtractor 208, and provides x and z to multiplier 207, whichprovides its output to adder/subtractor 208.

In some embodiments, structure 100 or 200 may be implemented in aprogrammable device, such as an FPGA, either in programmable logic, orin a combination of programmable logic and fixed logic (e.g., addersand/or multipliers) if provided. For example, FPGAs in the STRATIX®family of FPGAs available from Altera Corporation, of San Jose, Calif.,include digital signal processing blocks having multipliers and addersand programmable interconnect for connecting the multipliers and adders.Such an FPGA may be configured to use the adders and/or multipliers, aswell as any programmable logic that may be needed, to implementstructure 100 or 200.

The input range can be further limited to a smaller range between π/8and π/4, which may provide a more accurate CORDIC result than a rangebetween π/4 and π/2. According to such an implementation, which may becarried out using a structure 300 as shown in FIG. 3, which may beimplemented as circuitry, when the input is between 0 and π/8, the inputis subtracted from π/4, creating a new value between π/8 and π/4. Whenthe input is between 3π/8 and π/2, π/4 is subtracted from the input,also creating a new value between π/8 and π/4. If the input is betweenπ/8 and 3π/8, the input may be passed through unchanged.

As seen in FIG. 3, input multiplexer 302 selects either input 303, orthe difference 304 between π/4 and input 303, or the difference 314between input 303 and π/4. The selected input is used in CORDIC engine301 which may be substantially identical to CORDIC engine 101.

For the case where difference 304 is used, the outputs of CORDIC engine301 are processed by output stage 320 in accordance with the followingidentities:

sin(A−B)=sin(A)cos(B)−sin(B)COS(A)

cos(A−B)=cos(A)cos(B)+sin(A)sin(B)

If A=π/4, and B=π/4−θ, then A−B=π/4−(π/4−θ)=θ. Also, SIN (π/4)=COS(π/4)=2_(−0.5).

It follows, then, that:

$\begin{matrix}{{{SIN}(\theta)} = {{SIN}\left( {A - B} \right)}} \\{= {{{{SIN}\left( {\pi/4} \right)}{{COS}\left( {{\pi/4} - \theta} \right)}} - {{{SIN}\left( {{\pi/4} - \theta} \right)}{{COS}\left( {\pi/4} \right)}}}} \\{= {2^{- 0.5}{\left( {{{COS}\left( {{\pi/4} - \theta} \right)} - {{SIN}\left( {{\pi/4} - \theta} \right)}} \right).}}}\end{matrix}$

Similarly:

$\begin{matrix}{{{COS}(\theta)} = {{COS}\left( {A + B} \right)}} \\{= {{{{COS}\left( {\pi/4} \right)}{{COS}\left( {{\pi/4} - \theta} \right)}} + {{{SIN}\left( {{\pi/4} - \theta} \right)}{{SIN}\left( {\pi/4} \right)}}}} \\{= {2^{- 0.5}{\left( {{{COS}\left( {{\pi/4} - \theta} \right)} + {{SIN}\left( {{\pi/4} - \theta} \right)}} \right).}}}\end{matrix}$

For the case where difference 314 is used, the outputs of CORDIC engine301 are processed by output stage 320 in accordance with the followingidentities:

sin(A+B)=sin(A)cos(B)+sin(B)COS(A)

cos(A+B)=cos(A)cos(B)−sin(A)sin(B)

If A=π/4, and B=θ−π/4, then A+B=π/4+(θ−π/4)=θ. Again,SIN(π/4)=COS(π/4)=2^(−0.5).

It follows, then, that:

$\begin{matrix}{{{SIN}(\theta)} = {{SIN}\left( {A + B} \right)}} \\{= {{{{SIN}\left( {\pi/4} \right)}{{COS}\left( {\theta - {\pi/4}} \right)}} + {{{SIN}\left( {\theta - {\pi/4}} \right)}{{COS}\left( {\pi/4} \right)}}}} \\{= {2^{- 0.5}{\left( {{{COS}\left( {\theta - {\pi/4}} \right)} + {{SIN}\left( {\theta - {\pi/4}} \right)}} \right).}}}\end{matrix}$

Similarly:

$\begin{matrix}{{{COS}(\theta)} = {{COS}\left( {A + B} \right)}} \\{= {{{{COS}\left( {\pi/4} \right)}{{COS}\left( {\theta - {\pi/4}} \right)}} - {{{SIN}\left( {\theta - {\pi/4}} \right)}{{SIN}\left( {\pi/4} \right)}}}} \\{= {2^{- 0.5}{\left( {{{COS}\left( {\theta - {\pi/4}} \right)} - {{SIN}\left( {\theta - {\pi/4}} \right)}} \right).}}}\end{matrix}$

This is implemented in output stage 320 by adder/subtractor 321 whichadds the y (SIN) datapath to, or subtracts it from, the x (COS)datapath, and by multiplier 322 which multiplies that difference by2^(−0.5) (indicated in FIG. 3 as SIN(π/4)). Output stage 320 also mayinclude a multiplexing circuit 323 (similar to the combination ofmultiplexers 206, 216 in FIG. 2) for implementing the pass-through ofthe correct datapath (SIN or COS, depending on the desired function) fora case where the input 303 is between π/8 and 3π/8 and was passedthrough input multiplexer 302 unchanged.

Thus, as compared to embodiment 100 of FIG. 1, only one additionalsubtractor and one additional constant multiplication are needed forincreased accuracy.

Alternatively, if the input is between π/4 and 3π/8, it also falls underembodiment 100 of FIG. 1, and it can be reflected around π/4 bysubtracting the input from π/2, switching SIN and COS results to get thedesired output. This also may be useful for implementing other types ofalgorithms to calculate SIN and COS values where a small input range canbe used to improve the convergence rate.

A “terminated CORDIC” implementation similar to embodiment 200 of FIG. 2can be used with embodiment 300 of FIG. 3. Such an implementation 400 isshown in FIG. 4.

In a case where signal 105 selects the direct input 408, then, as inembodiment 200, only one of the SIN/COS datapaths 401, 402 is multipliedat 411, 412 by the z datapath 403 and then, at 421, is added to orsubtracted from the other of the SIN/COS datapaths 401, 402, and thatresult is multiplied at 422 by 2^(−0.5). Whether datapath 401 or 402 ismultiplied by datapath 403 is determined by signal(s) 435, output bylogic 425 which, based on comparison signal 105 and signal 115 whichindicates whether sine or cosine is desired, causes one of multiplexers413, 423 to select datapath 403 for input to a respective one ofmultipliers 411, 412, and other of multiplexers 413, 423 to select thevalue ‘1’ for input to the other respective one of multipliers 411, 412.In this case, signal(s) 435 also determines whether adder/subtractor 421adds or subtracts, and causes multiplexer 443 to select the value ‘0’for addition at 453 to sum/difference 421. Sum 453 is then multiplied bysin(π/4) (i.e., 2^(−0.5)) at 422.

In a case where signal 105 selects difference input 404 (π/4−θ), becauseinput 408 is less than π/8, then, depending on whether sine or cosine isdesired, the following relationships, as discussed above, will apply:

SIN(θ)=2^(−0.5)(COS(π/4−θ)−SIN(π/4−θ))

COS(θ)=2^(−0.5)(COS(π/4−θ)+SIN(π/4−θ))

Similarly, in a case where signal 105 selects difference input 444(θ−π/4), because input 408 is greater than 3π/8, then, depending onwhether sine or cosine is desired, the following relationships, asdiscussed above, will apply:

SIN(θ)=2^(−0.5)(COS(θ−π/4)+SIN(θ−π/4))

COS(θ)=2^(−0.5)(COs(θ−π/4)−SIN(θ−π/4))

In a terminated CORDIC implementation,

COS(φ)=x+yz

SIN(gyp)=y−xz

Therefore, in a terminated CORDIC case where signal 105 selectsdifference input 404 (π/4−θ),

$\begin{matrix}{{{SIN}(\theta)} = {2^{- 0.5}\left( {x + {yz} - \left( {y - {xz}} \right)} \right)}} \\{= {2^{- 0.5}\left( {x - y + \left( {{yz} + {xz}} \right)} \right)}}\end{matrix}$ $\begin{matrix}{{{COS}(\theta)} = {2^{- 0.5}\left( {x + {yz} + \left( {y - {xz}} \right)} \right)}} \\{= {2^{- 0.5}\left( {x + y + \left( {{yz} - {xz}} \right)} \right)}}\end{matrix}$

Similarly, in a terminated CORDIC case where signal 105 selectsdifference input 444 (θ−π/4),

$\begin{matrix}{{{SIN}(\theta)} = {2^{- 0.5}\left( {x + {yz} + \left( {y - {xz}} \right)} \right)}} \\{= {2^{- 0.5}\left( {x + y + \left( {{yz} - {xz}} \right)} \right)}}\end{matrix}$ $\begin{matrix}{{{COS}(\theta)} = {2^{- 0.5}\left( {x + {yz} - \left( {y - {xz}} \right)} \right)}} \\{= {2^{- 0.5}\left( {x - y + \left( {{yz} + {xz}} \right)} \right)}}\end{matrix}$

For these implementations, signal(s) 435 would cause both ofmultiplexers 413, 423 to select datapath 403 for input to multipliers411, 412. Signal(s) 435 also would determine whether adders/subtractors421 and 431 add or subtract, respectively, and would causes multiplexer443 to select the sum/difference 431 for addition at 453 tosum/difference 421. Sum 453 is then multiplied by sin(π/4) (i.e.,2^(−0.5)) at 422.

When implementing embodiment 400 in one of the aforementioned STRATIX®FPGAs, one of the aforementioned digital signal processing blocks,having multipliers and adders, can be used at 410 to provide multipliers411, 412 and adder/subtractor 421. The digital signal processing blocksof such FPGAs, for example, are well-suited for performing two36-bit-by-18-bit multiplications which may be used for this purpose. Onesuch implementation is described at page 5-21 of the Stratix III DeviceHandbook, Volume 1 (ver. 2, March 2010), published by AlteraCorporation, which is hereby incorporated by reference herein.

Other identity-based approaches can be used to simplify the calculationsof other trigonometric functions.

For example, for tan(θ), the normalized or range-reduced input is−π/2≦θ≦π/2, while the output is between negative infinity and positiveinfinity. The following identity holds true for the tangent function:

${\tan \left( {a + b} \right)} = \frac{{\tan (a)} + {\tan (b)}}{1 - {{\tan (a)} \times {\tan (b)}}}$

By judiciously breaking up θ, one can break up the problem ofcalculating tan(θ) into easily calculable pieces. In this case, it maybe advantageous to break up tan(θ) into three pieces. This case be doneby substituting c for b, and a+b for a, above. Thus:

${\tan \left( {a + b + c} \right)} = \frac{{\tan \left( {a + b} \right)} + {\tan (c)}}{1 - {{\tan \left( {a + b} \right)} \times {\tan (c)}}}$

Expanding further:

${\tan \left( {a + b + c} \right)} = \frac{\frac{{\tan (a)} + {\tan (b)}}{1 - {{\tan (a)} \times {\tan (b)}}} + {\tan (c)}}{1 - {\left( \frac{{\tan (a)} \times {\tan (b)}}{1 - {{\tan (a)} \times {\tan (b)}}} \right) \times {\tan (c)}}}$

Although this looks much more complex than the original identity, theproperties of the tangent function, and the precision of singleprecision arithmetic, can be used to greatly simplify the calculation.

As with many trigonometric functions, tan(θ)≈θ for small θ. The inputrange for the tangent function is defined as −π/2≦θ≦π/2. In singleprecision floating point arithmetic—e.g., under the IEEE754-1985standard—the exponent is offset by 127 (i.e., 2° becomes 2¹²⁷). If theinput exponent is 115 or less (i.e., a true exponent of −12 or less),the error between tan(x) and x is below the precision of the numberformat, therefore below that value, tan(θ) can be considered equal to θ.

The tangent function is therefore defined for a relatively narrowexponent range, between 115 and 127, or 12 bits of dynamic range. ForIEEE754-1985 arithmetic, the precision is 24 bits. The input number cantherefore be represented accurately as a 36-bit fixed point number (24bits precision +12 bits range).

Such a 36-bit fixed point number can then be split into threecomponents. If θ=a+b+c as indicated above, the upper 9 bits can bedesignated the c component, the next 8 bits can be designated the acomponent, and 19 least significant bits may be designated the bcomponent.

As discussed above, tan(θ)=θ for any value of θ that is smaller than2⁻¹². As the 19 least significant bits of a 36-bit number, b is smallerthan 2⁻¹⁷. Therefore, tan(b)=b and we can write:

${\tan \left( {a + b + c} \right)} = \frac{\frac{{\tan (a)} + b}{1 - {{\tan (a)} \times b}} + {\tan (c)}}{1 - {\left( \frac{{\tan (a)} + b}{1 - {{\tan (a)} \times b}} \right) \times {\tan (c)}}}$

The tangent of a is relatively small. The maximum value of a is slightlyless than 0.00390625₁₀ (tan(a)=0.00390627₁₀) and the maximum value of bis 0.00001526₁₀, which is also its tangent. Therefore, the maximum valueof tan(a)×b is 5.96×10⁻⁸, therefore the minimum value1−tan(a)×b=0.99999994₁₀. The maximum value of tan(a)+b is0.00392152866₁₀. The difference between that value, and that valuedivided by the minimum value of 1−tan(a)×b is 2.35×10⁻¹⁰, or about 32bits, which is nearly the entire width of a, b and c combined. In theworst case, where c is zero, this error would not be in the precision ofthe result either, which is only 24 bits.

The foregoing equation therefore can be further simplified to:

${\tan \left( {a + b + c} \right)} = \frac{{\tan (a)} + b + {\tan (c)}}{1 - {\left( {{\tan (a)} + b} \right) \times {\tan (c)}}}$

Insofar as a and c are 8 and 9 bits respectively, the tangents for allpossible bit combinations can be stored in a table with 36-bit data.Therefore the problem is reduced to a 36-bit fixed point multiplication,a 36-bit fixed point division, and a fixed point subtraction, althoughthe additions are floating point additions as described below.

An embodiment 500 of this tangent calculation is shown in FIG. 5 and maybe implemented in circuitry.

The input value 501 (θ) is first converted to a 36-bit fixed-pointnumber by shifting at 502 by the difference 503 between its exponent and127 (the IEEE754-1985 exponent offset value). The converted fixed-pointinput 504 is then split into three numbers: c—bits [36:28], a—bits[27:20], and b—bits [19:1]. Tan(c) is determined in lookup table 505 andtan(a) is determined in lookup table 506. Tan(a) and b, which are bothin fixed-point format, are added at 507. That sum must then benormalized to the exponent of c, which can range from 0 to 19 (127 to146 in single precision offset equivalent). The ‘tan(a)+b’ sum has amaximum exponent of −8 (119 in single precision offset equivalent), andis normalized at 508 for multiplying by tan(c) at 509 (for thedenominator) and adding to tan(c) at 510 (for the numerator).

The numerator is normalized at 511 and now exists as a floating-pointnumber. The local exponent (‘15’−‘c exponent’+‘a+b exponent’) is anumber that is relative to ‘1.0’, and is used to denormalize the productto a fixed point number again at 512.

The denominator product is subtracted from ‘1’ at 513. The difference isnormalized at 514. The difference is then inverted at 515 to form thedenominator.

The denominator is multiplied by the numerator at 516. Before thatmultiplication, the numerator exponent is normalized at 517. Theexponent is ‘119’ (which is the minimum value of c, or the maximum valueof b—the reference point to which the internal exponents are normalized)plus the numerator exponent plus the denominator exponent. Thedenominator exponent is the shift value from the final denominatornormalization 514—normally this would be considered a negative relativeexponent, and subtracted from any final exponent. However, because thedenominator is arithmetically inverted immediately following thenormalization, the exponent is converted from negative to positive, andcan therefore be added at this stage.

The result is rounded at 518 and is ready for use. However, if theexponent of the original input value 501 is less than 115, the outputand the input are considered the same—i.e., tan(θ)=θ. This isimplemented with the multiplexer 519, which selects as the final outputeither the rounded calculation result 520, or input 501, based oncontrol signal 521 which is determined (not shown) by the size of theexponent of input 501.

A double-precision tangent calculation may also be implemented.

As noted above, the following identity holds true for the tangentfunction:

${\tan \left( {a + b} \right)} = \frac{{\tan (a)} + {\tan (b)}}{1 - {{\tan (a)} \times {\tan (b)}}}$

By judiciously breaking up θ, again as above one can break up theproblem of calculating tan(θ) into easily calculable pieces. Once again,it may be advantageous to break up tan(θ) into three pieces bysubstituting b+c for b, above. Thus:

${\tan \left( {a + b + c} \right)} = \frac{{\tan (a)} + {\tan \left( {b + c} \right)}}{1 - {{\tan (a)} \times {\tan \left( {b + c} \right)}}}$

One can define a to be a 9-bit value, for the range of 1.11111111 downto 0.0000000—i.e., the implied leading ‘1’ for the mantissa when thenumber of radians is 1 or greater, and the most significant 8 bits ofthe mantissa to the right of the decimal point. b can be defined as thenext 9 bits down, while c value will be the least significant bits ofthe mantissa. For smaller arguments, where the exponent is less than1023 (i.e., for double-precision values less than 1), c can still have53 significant bits (one implied bit followed by 52 mantissa bits), butthe invention applies regardless of the value of the exponent.

One can start with the less significant bits, b and c:

${\tan \left( {b + c} \right)} = \frac{{\tan (b)} + {\tan (c)}}{1 - {{\tan (b)} \times {\tan (c)}}}$

For c as defined above, the maximum value of c will be just below 2⁻¹⁷,and therefore, because for small α, tan(α)≈α, the maximum value oftan(c) will be around 2⁻¹⁷ as well. If a series expansion of tan(α) is:

${{\tan (\alpha)} = {\alpha + \frac{\alpha^{3}}{3} + \frac{2\alpha^{5}}{15} + \ldots}}\mspace{11mu},$

then when α=c, tan(c) is at most around 2⁻¹⁷, then the second (c³) termwill be about 35 binary positions to the right of the input argument,and the third (c⁵) term will be almost 70 binary positions to the rightof the input argument. The second term will therefore contribute up to52−35=17 bits to the mantissa. The third term may contribute a roundinginput very occasionally, and can be ignored for double precisioncalculations.

The second (c³) term can be reasonably accurately be calculated withthree 18-bit fixed-point multipliers, in a tree format. One multipliercan be used to multiply c by itself to yield c² (which is then rightshifted by 18 bits). A second multiplier can be used to multiply c by174763 to scale it by ⅓ to account for the use of fixed-point (and thatresult is then right shifted by 18 bits). Those two results aremultiplied by the third multiplier and that result, right-shifted by 35bits, is then added to c. At each step, the upper 18 bits of c are usedfor the multiplier inputs. For higher accuracy, 27-bit multipliers canalso be used, operating on the upper 27 bits of c. This can beimplemented using three 18×18 multipliers and one 55-bit adder, which,in a programmable device, may be implemented in programmable logic.

As described above, b is a 9-bit value and therefore, if non-zero, is inthe range of around 2⁻¹⁷ to around 2⁻⁸, which means that tan(b) is aboutthe same. The 9-bit input range corresponds to 512 values, which caneasily be pre-computed in stored in a look-up table. 512 64-bit valueswould occupy 32 Kb, which can easily be accommodated, e.g., in two M20Kmemories of a programmable logic device sold by Altera Corporation underthe name STRATIX® V.

To calculate tan(b+c), the look-up table result for tan(b) is added tothe calculation of tan(c). Because tan(b) has only a narrow range, thisaddition is smaller than a full floating-point addition, so can beefficiently implemented as a wider fixed-point addition, followed by anormalization.

The next step is to divide by (1−tan(b)tan(c)). This can be done usingthe binomial theorem, according to which:

$\frac{N}{1 - x} = \frac{{N\left( {1 + x} \right)}\left( {1 + x^{2}} \right)}{1 - x^{4}}$

Here, we can set N=tan(b)+tan(c) and x=tan(b)tan(c). The maximum valueof x would be about 2⁻²⁵, so x⁴ would be around 2⁻¹⁰⁰ which can beignored in this case. If b or c were smaller, then x would beproportionally smaller as well.

The (1−x) term can be constructed using only fixed-point arithmetic,multiplying the 27-bit fixed-point values of b and c. The multiplicationof the numerator N by (1+x)—i.e., (1+tan(b)tan(c))—can be implemented ina 54×54 multiplier. The (1+x²) term does not have to be multiplied out,but can be accurately estimated.

Specifically, because the value of x² is very small (about 50 bits tothe right of the ‘1’), it is easier to add a correction factor to theleast significant portion of the mantissa of N(1+x), rather thanmultiplying N(1+x) by (1+x²). First, the value of x² can be estimated bysquaring some of the most significant bits (MSBs) of the tan(b)tan(c)product (i.e., some of the MSBs of x). Only a few bits (e.g., 3-5 bits)are needed because the contribution to the (1+x²) total is so small.Therefore, this multiplication could be implemented in either hardmultipliers or programmable logic (if implemented in a programmablelogic device).

Remembering that N=tan(b)+tan(c) and that the correction factor is meantto approximate the contribution of (1+x²) to N(1+x)(1+x²), in view ofthe magnitudes of b and c, only the most significant bits of the tan(b)term would have an impact on the result, so the correction factor can beaccurately estimated by multiplying a few MSBs (again, e.g., 3-5 bits)of tan(b) by a few MSBs of the square of tan(b)tan(c). This result isthen added to the least significant bits of the output of the upper 54bits of the 54×54 multiplier (i.e., to N(1+x)), resulting in an accurateapproximation of tan(b+c). This is achieved using one double-precisionnormalization, one 27×27 multiplier and one 54×54 multiplier.

The final identity, combining tan(a)—which, like tan(b), can be derivedfrom a look-up table—with tan(b+c), can be calculated as afloating-point operation, using a floating-point multiplier, twofloating-point adders, and a floating-point divider. The range oftan(b+c) is small compared to that of tan(a). tan(b+c) has a range of 0to 2⁻⁸, while tan(a) has a range of 2⁻⁸ to about 2⁸, ensuring that theproduct tan(a)tan(b+c) will never exceed 1.

An embodiment 550 of a portion of this double-precision tangentcalculation, and particularly the tan(b)+tan(c) portion, is shown inFIG. 6 and may be implemented in circuitry.

As noted above, values for tan(b) may be pre-calculated and stored in alook-up table 565, while tan(c) may be calculated as a series expansionas discussed above. These may be 18 bits or 27 bits as discussed above.tan(b) is input from look-up table 565 at 551 and tan(c) (the leastsignificant bits of θ) is input at 552, and the two values are added at553 to provide the N term (above) and multiplied at 554, which may be a54×54 multiplier, to provide the x term (above).

The x term is right-shifted at 555 by an amount equal to the differentbetween the exponent of tan(b), which is output from the look-up table,and the exponent of tan(c), which is determined in the calculationdescribed above. The x term is then explicitly added to ‘1’ or invertedto produce a one's-complement value (neither option shown) to generatethe (1+x) term (above), which is multiplied by the N term at 556.Because x is much smaller than ‘1’, the addition of ‘1’ to x is a simplebit insertion to the left of the decimal point.

The aforementioned correction factor to replace the (1+x²) term may bederived as follows:

N(1+x)(1+x ²)=(N+Nx)(1+x ²)=N+Nx+Nx ² +Nx ³

Nx³ will be smaller than the least significant bit of the result and socan be ignored, leaving N+Nx+Nx²=N(1+x)+Nx². Nx² may be approximated bymultiplying the upper bits of x (e.g., the four uppermost bits in FIG.5) by themselves at 557, and then multiplying that product by the upperbits (e.g., the eight uppermost bits in FIG. 5) of tan(b) at 558. Again,only the upper bits are kept (e.g., the eight uppermost bits in FIG. 5)and right-shifted at 559. The amount of the shift is derived from theexponents as for the 1+x term, but is doubled to account for thesquaring. This result is then added at 560 to the least significant bitsof the output of the upper bits (e.g., the 54 uppermost bits in FIG. 5)of multiplier 554 (i.e., to N(1+x)) to provide an accurate approximationof tan(b+c).

The remainder of the double-precision tangent calculation, combiningtan(a) with tan(b+c), is not shown, but as discussed above can becalculated as a floating-point operation.

It should be noted that for either the single-precision tangentcalculation described above or the double-precision tangent calculationdescribed above, any one or more of the ranges a, b and c can be furtherbroken down into subranges and a tangent value can be determined foreach subrange by either a look-up table or by a calculation such asthose described above.

For inverse tangent (i.e., arctan(x) or tan⁻¹(x)), the situation isreversed in that the input is between negative infinity and positiveinfinity, while the normalized or range-reduced output is −π/2≦θ≦+π/2.Once again, the problem can be broken down into input ranges. Thus, asshown in FIG. 7, for −1≦x≦+1, arctan(x) is relatively linear, and has anoutput in the range −π/4≦θ≦+π/4. Viewed on an intermediate scale in FIG.8, for −10₁₀≦x≦+10₁₀, arctan(x) shows inflection points past ±1,flattening out to an output in the range −π/2≦θ≦+π/2. Viewed on a largerscale in FIG. 9, for −100₁₀≦x≦+100₁₀, arctan(x) remains in an outputrange of −π/2≦θ≦+π/2. In IEEE754-1985 single-precision arithmetic, with24 bits of precision and an exponent up to 127, the output must be exactfor a set of 8338608₁₀ (2²³) points in 127 segments along the inputcurve.

The calculation can be simplified by separately handling inputs ofmagnitude less than 1 and inputs of magnitude greater than 1.

Considering first inputs of magnitude less than 1, the followingidentity may be applied:

${\arctan (a)} = {{\arctan (b)} + {\arctan \left( \frac{a - b}{1 + {ab}} \right)}}$

If b is close enough to a, then c=(a−b)/(1+ab) is very small andarctan(c)≈c. If a has a maximum value of 1, and b is made equal to the 8or 10 most significant bits of a, then c will have a maximum value of1/256 for 8 bits, or 1/1024 for 10 bits. The inverse tangent 1/256(0.00390625₁₀) is 0.00390623₁₀. The error is almost at the floor of theprecision of the input (23 bits). The inverse tangent of 1/1024(0.0009765625₁₀) is 0.000976522₁₀, which has an error below the leastsignificant bit of the input range.

The subrange b can easily be separated from a by truncation. The (a−b)term is made up of the truncated bits. ab will always be less than 1, sothe term 1+ab can be calculated without an adder, by directlyconcatenating a ‘1’ to the ab term. c can therefore be calculatedeasily. Values for arctan(b) where b<1 can be stored in a lookup table.Therefore, arctan(a) can be determined by looking up arctan(b) in thetable and adding c to the lookup result.

If a is greater than (or equal to) 1, then the following identity can beused:

${\arctan (a)} = {\frac{\pi}{2} - {\arctan \left( \frac{1}{a} \right)}}$

The inverse tangent of the inverse of the input may be determined asdescribed above for inputs less than 1 and then the desired result isobtained by subtracting from π/2.

The input mantissa is converted to a 36-bit number, by appending a ‘1’to the left of the most significant bit, and appending a number of ‘0’bits to the right of the least significant bit. The exponent of thisnumber is 127−(input_exponent−127)−1=253−input exponent. Once thecorrect floating point input has been selected, the number is convertedto a fixed point equivalent by right shifting it from the referencepoint of 1. This should not reduce accuracy of the result given that36-bit numbers are used. If the number has an exponent of 117 (for aright shift of 10 bits), there will still be 26 valid bits in the 36-bitmagnitude, and only 24 bits are needed for single-precision floatingpoint representation.

An embodiment 900 of this inverse tangent calculation is shown in FIG.10 and may be implemented in circuitry.

The mantissa of the input number (with leading ‘1’ and trailing zero(es)appended as discussed above) is input at 901, while the exponent of theinput number is input at 902. Multiplexers 903, 904 select the unalteredinput mantissa and exponent if the input value is less than 1.0 asdetermined at 905. Otherwise, multiplexers 903, 904 select inverse 906and the new exponent (original exponent subtracted from ‘253’). Inverse906 can be computed using any suitable inverse calculation module 907.The input is then normalized at 908 to a fixed-point representation 909.

The uppermost bits 910 are input to lookup table 911 and are also inputto multiplier 912 along with all bits 913—this is the ab calculationdiscussed above. a-b is the remaining bits 914.

The ab product 915 is added to ‘1’ at 916 to form the 1+ab sum 917 whichis inverted, again using any suitable inversion module 918 to form1/(1+ab) quotient 919, which is multiplied at 920 by a-b term 914,forming the c term (a-b)/(1+ab). c term 921 is added at 922 to arctan(b)as determined in lookup table 911.

If the original input was less than ‘1’, then sum 922 is the result,which is selected by control signal 905 at multiplexer 923 followingnormalization at 924. Sum 922 is also subtracted from π/2 at 925 andnormalized at 926, and if the original input was greater than (or equalto) ‘1’, then difference 925, as normalized at 926, is the result, whichis selected by control signal 905 at multiplexer 923. Any necessaryrounding, exception handling, etc., is performed at 927 to provideresult 928.

In the input range of exponents 115-120 (as an example), someinaccuracies in the output (still limited to a small number of leastsignificant bits) may occur. One way to solve this is to use a second,smaller lookup table (not shown) for a limited subset of mostsignificant valid bits—e.g., 6 bits. The b value would be the upper 6bits of the subrange, and the a−b value would be the lower 20 bits. Tomaintain the maximum amount of precision, the table could containresults that are normalized to the subrange—for example if the largestexponent in the subrange were 120, then 1.9999₁₀×2¹²⁰ would be a fullynormalized number, with all other table entries relative to that one.The c value would have to be left-shifted so that it would have thecorrect magnitude in relation to the b table output. One way (andpossibly the most accurate way) to implement this would be to take thea−b value from before the fixed point shifter. That is, instead offixed-point representation 909, the output of multiplexer 903 could beused directly. An additional multiplexer (not shown) could be providedto select between the output of multiplexer 903 for smaller exponentsand the output of normalizer 908 for larger exponents.

Once inverse tangent can be calculated, inverse cosine and inverse sinecan easily be calculated based on:

${\arccos (x)} = {2{\arctan \left( \frac{1 - x}{\sqrt{1 - x^{2}}} \right)}}$and arcsin (x) = π/2 − arccos (x).

An embodiment 1000 of the inverse cosine calculation is shown in FIG. 11and may be implemented in circuitry.

The input argument x is input as sign 1001, mantissa 1002 and exponent1003 to preprocessing module 1100, shown in more detail in FIG. 12.Preprocessing module 1100 prepares the 1−x numerator term 1004 and the1−x² denominator term 1005 from x. The inverse square root ofdenominator term 1005 is taken at inverse square root module 1006, whichbe any suitable inverse square root module.

The mantissa 1007 of the inverse square root is multiplied at 1008 bythe mantissa 1009 of the numerator term, while the exponent 1010 of theinverse square root is added at 1011 to the exponent 1012 of thenumerator term, and ‘127’ is subtracted from the exponent at 1013. Theresult is input to an inverse tangent module 1014 which may be inversetangent module 900, above.

The inverse tangent module 1014 outputs a 36-bit fixed point valuebetween 0 and π/2. If the input number is positive, the inverse cosineof that input must lie in the first (or fourth) quadrant, and the outputof inverse tangent module 1014 is used directly. This is implemented byexclusive-OR gate 1024 and AND-gate 1034. Sign bit 1001 will be a ‘0’,meaning that XOR-gate 1024 will pass the output of inverse tangentmodule 1014 without change, and there will be no contribution at adder1044 from AND-gate 1034. If the input number is negative, the inversecosine of that input must lie in the second (or third) quadrant. In thatcase, the inverse cosine value can be calculated by subtracting theoutput of inverse tangent module 1014 from π. Sign bit 1001 will be a‘1’, meaning that XOR-gate 1024 will pass the 1's-complement negative ofthe output of inverse tangent module 1014, while AND-gate 1034 will passthe value π. The sign bit is also used as a carry input (not shown) toadder 1044, converting the 1's-complement number to 2's-complementformat, and adder 1044 outputs the difference between π and the outputof inverse tangent module 1014.

Output 1015 is the inverse cosine. By subtracting inverse cosine output1015 from π/2 at 1016, inverse sine 1017 can be determined. However, forinputs having real exponents less than −12 (IEEE754-1985 exponents lessthan 115), it would be more accurate to rely on arcsin(x)≈x than to relyon the calculated value.

FIG. 12 shows preprocessing module 1100, including numerator portion1101 and denominator portion 1102. The input mantissa (with leading ‘1’and trailing zero(es)) is input to numerator portion 1101 at 1103 and todenominator portion 1102 at 1104, while the input exponent is input tonumerator portion 1101 at 1105 and to denominator portion 1102 at 1106.

On the numerator side, ‘127’ is subtracted from the exponent at 1107 todetermine the “real” exponent, which is then used in shifter 1108 toturn the input mantissa into a fixed-point number 1109, which issubtracted at 1110 from ‘1’ to yield the numerator 1−x. The number ofleading zeroes in the result are counted at count-leading-zeroes module1111 and used at shifter 1112 to normalize the numerator mantissa and atsubtractor 1113 to determine the IEEE754-1985 exponent by subtractingfrom ‘127’.

On the denominator side, the input mantissa is multiplied by itself atmultiplier 1114 to determine x² value 1115. The input exponent isleft-shifted by one place at 1116 and subtracted from ‘253’ at 1117 todetermine how far to right-shift value 1115 at 1118 to yield afixed-point representation of x². The fixed-point representation of x²is subtracted from ‘1’ at 1119 to yield denominator 1−x² at 1120. Thenumber of leading zeroes in value 1120 are counted atcount-leading-zeroes module 1121 and used at shifter 1122 to normalizethe denominator mantissa and at subtractor 1123 to determine theIEEE754-1985 exponent by subtracting from ‘127’.

The trigonometric function calculating structures described above can beimplemented as dedicated circuitry or can be programmed intoprogrammable integrated circuit devices such as FPGAs. As discussed, inFPGA implementations, certain portions of the circuitry, particularlyinvolving multiplications and combinations of multiplications asindicated, can be carried out in specialized processing blocks of theFPGA, such as a DSP block, if provided in the FPGA.

Instructions for carrying out a method according to this invention forprogramming a programmable device to implement the trigonometricfunction calculating structures described above may be encoded on amachine-readable medium, to be executed by a suitable computer orsimilar device to implement the method of the invention for programmingor configuring PLDs or other programmable devices to perform additionand subtraction operations as described above. For example, a personalcomputer may be equipped with an interface to which a PLD can beconnected, and the personal computer can be used by a user to programthe PLD using a suitable software tool, such as the QUARTUS® II softwareavailable from Altera Corporation, of San Jose, Calif.

FIG. 13 presents a cross section of a magnetic data storage medium 1200which can be encoded with a machine executable program that can becarried out by systems such as the aforementioned personal computer, orother computer or similar device. Medium 1200 can be a floppy disketteor hard disk, or magnetic tape, having a suitable substrate 1201, whichmay be conventional, and a suitable coating 1202, which may beconventional, on one or both sides, containing magnetic domains (notvisible) whose polarity or orientation can be altered magnetically.Except in the case where it is magnetic tape, medium 1200 may also havean opening (not shown) for receiving the spindle of a disk drive orother data storage device.

The magnetic domains of coating 1202 of medium 1200 are polarized ororiented so as to encode, in manner which may be conventional, amachine-executable program, for execution by a programming system suchas a personal computer or other computer or similar system, having asocket or peripheral attachment into which the PLD to be programmed maybe inserted, to configure appropriate portions of the PLD, including itsspecialized processing blocks, if any, in accordance with the invention.

FIG. 14 shows a cross section of an optically-readable data storagemedium 1210 which also can be encoded with such a machine-executableprogram, which can be carried out by systems such as the aforementionedpersonal computer, or other computer or similar device. Medium 1210 canbe a conventional compact disk read-only memory (CD-ROM) or digitalvideo disk read-only memory (DVD-ROM) or a rewriteable medium such as aCD-R, CD-RW, DVD-R, DVD-RW, DVD+R, DVD+RW, or DVD-RAM or amagneto-optical disk which is optically readable and magneto-opticallyrewriteable. Medium 1210 preferably has a suitable substrate 1211, whichmay be conventional, and a suitable coating 1212, which may beconventional, usually on one or both sides of substrate 1211.

In the case of a CD-based or DVD-based medium, as is well known, coating1212 is reflective and is impressed with a plurality of pits 1213,arranged on one or more layers, to encode the machine-executableprogram. The arrangement of pits is read by reflecting laser light offthe surface of coating 1212. A protective coating 1214, which preferablyis substantially transparent, is provided on top of coating 1212.

In the case of magneto-optical disk, as is well known, coating 1212 hasno pits 1213, but has a plurality of magnetic domains whose polarity ororientation can be changed magnetically when heated above a certaintemperature, as by a laser (not shown). The orientation of the domainscan be read by measuring the polarization of laser light reflected fromcoating 1212. The arrangement of the domains encodes the program asdescribed above.

A PLD 140 programmed according to the present invention may be used inmany kinds of electronic devices. One possible use is in a dataprocessing system 1400 shown in FIG. 15. Data processing system 1400 mayinclude one or more of the following components: a processor 1401;memory 1402; I/O circuitry 1403; and peripheral devices 1404. Thesecomponents are coupled together by a system bus 1405 and are populatedon a circuit board 1406 which is contained in an end-user system 1407.

System 1400 can be used in a wide variety of applications, such ascomputer networking, data networking, instrumentation, video processing,digital signal processing, or any other application where the advantageof using programmable or reprogrammable logic is desirable. PLD 140 canbe used to perform a variety of different logic functions. For example,PLD 140 can be configured as a processor or controller that works incooperation with processor 1401. PLD 140 may also be used as an arbiterfor arbitrating access to a shared resources in system 1400. In yetanother example, PLD 140 can be configured as an interface betweenprocessor 1401 and one of the other components in system 1400. It shouldbe noted that system 1400 is only exemplary, and that the true scope andspirit of the invention should be indicated by the following claims.

Various technologies can be used to implement PLDs 140 as describedabove and incorporating this invention.

It will be understood that the foregoing is only illustrative of theprinciples of the invention, and that various modifications can be madeby those skilled in the art without departing from the scope and spiritof the invention. For example, the various elements of this inventioncan be provided on a PLD in any desired number and/or arrangement. Oneskilled in the art will appreciate that the present invention can bepracticed by other than the described embodiments, which are presentedfor purposes of illustration and not of limitation, and the presentinvention is limited only by the claims that follow.

What is claimed is:
 1. Circuitry for computing a tangent function of aninput value, said circuitry comprising: first look-up table circuitrythat stores pre-calculated tangent values of a limited number of samplevalues; circuitry for inputting bits of said input value of mostsignificance as inputs to said first look-up table circuitry to look upone of said pre-calculated tangent values as a first intermediatetangent value; circuitry for calculating a second intermediate tangentvalue from one or more ranges of remaining bits of said input value; andcircuitry for combining said first intermediate tangent value and saidsecond intermediate tangent value to yield said tangent function of saidinput value.
 2. The circuitry of claim 1 wherein: said circuitry forcalculating a second intermediate tangent value from one or more rangescomprises, for each respective one of said one or more ranges:respective additional look-up table circuitry for outputting arespective third intermediate tangent value from a respective firstsubrange of said respective one of said one or more ranges; respectiveadditional circuitry for calculating a respective fourth intermediatetangent value from a respective second subrange of said respective oneof said one or more ranges; and respective additional circuitry forcombining said respective third intermediate tangent value and saidrespective fourth intermediate tangent value to yield said secondintermediate tangent value.
 3. The circuitry of claim 2 furthercomprising, for each of one or more of said subranges, respectivefurther look-up table circuitry, respective further circuitry forcalculating, and respective further circuitry for combining.
 4. Thecircuitry of claim 1 wherein circuitry for calculating one of saidintermediate tangent values for one of said ranges of remaining bits ofleast significance approximates said one of said intermediate tangentvalues by setting said one of said intermediate tangent values equal tosaid one of said ranges of remaining bits of least significance.
 5. Thecircuitry of claim 1 wherein circuitry for calculating one of saidintermediate tangent values for one of said ranges of remaining bits ofleast significance calculates said one of said intermediate tangentvalues as a power series.
 6. The circuitry of claim 1 wherein saidcircuitry for combining includes circuitry for dividing.
 7. Thecircuitry of claim 6 wherein said circuitry for dividing performsdivision by approximation.
 8. The circuitry of claim 7 wherein saidcircuitry for dividing performs division as a power series.
 9. Thecircuitry of claim 8 wherein said circuitry for dividing calculateshigher-order terms of said power series as an additive approximation.10. The circuitry of claim 1 wherein: said circuitry for calculating asecond intermediate value comprises circuitry for computing a seriesexpansion of a tangent of a sum of bits of said input value ofintermediate significance and bits of said input value of leastsignificance.
 11. The circuitry of claim 10 wherein said circuitry forcomputing a series expansion comprises: circuitry for adding said firstintermediate tangent value and said bits of said input value of leastsignificance to provide a first interim value; circuitry for multiplyingsaid first intermediate tangent value and said bits of said input valueof least significance to provide a second interim value; circuitry foradding said second interim value to ‘1’ to provide a third interimvalue; circuitry for multiplying said first interim value by said thirdinterim value to provide a fourth interim value; circuitry forapproximating a sum of ‘1’ and a square of said second interim value;and circuitry for adding said approximated sum to said fourth interimvalue.
 12. The circuitry of claim 11 wherein said circuitry forapproximating a sum or ‘1’ and a square of said second interim valuecomprises: circuitry for multiplying upper bits of said second interimvalue by themselves to provide an approximation of said square of saidsecond interim value; and circuitry for multiplying said approximationof said square of said second interim value by said first intermediatetangent value.
 13. The circuitry of claim 12 wherein: said upper bits ofsaid second interim value comprise between three bits and five bits ofsaid second interim value.
 14. The circuitry of claim 12 wherein:circuitry for adding said approximated sum to said fourth interim valueadds, to said fourth interim value, upper bits of output of saidcircuitry for multiplying said approximation of said square of saidsecond interim value by said first intermediate tangent value.
 15. Amethod of configuring a programmable integrated circuit device ascircuitry for computing a tangent function of an input value, saidmethod comprising: configuring first look-up table circuitry that storespre-calculated tangent values of a limited number of sample values;configuring circuitry for inputting bits of said input value of mostsignificance as inputs to said first look-up table circuitry to look upone of said pre-calculated tangent values as a first intermediatetangent value; configuring circuitry for calculating a secondintermediate tangent value from one or more ranges of remaining bits ofsaid input value; and configuring circuitry for combining said firstintermediate tangent value and said second intermediate tangent value toyield said tangent function of said input value.
 16. The method of claim15 wherein: said configuring circuitry for calculating a secondintermediate tangent value from one or more ranges comprisesconfiguring, for each respective one of said one or more ranges:respective additional look-up table circuitry for outputting arespective third intermediate tangent value from a respective firstsubrange of said respective one of said one or more ranges; respectiveadditional circuitry for calculating a respective fourth intermediatetangent value from a respective second subrange of said respective oneof said one or more ranges; and respective additional circuitry forcombining said respective third intermediate tangent value and saidrespective fourth intermediate tangent value to yield said secondintermediate tangent value.
 17. The method of claim 16 furthercomprising configuring, for each of one or more of said subranges,respective further look-up table circuitry, respective further circuitryfor calculating, and respective further circuitry for combining.
 18. Themethod of claim 15 wherein said configuring circuitry for calculatingone of said intermediate tangent values for one of said ranges ofremaining bits of least significance comprises configuring circuitrythat approximates said one of said intermediate tangent values bysetting said one of said intermediate tangent values equal to said oneof said ranges of remaining bits of least significance.
 19. The methodof claim 15 wherein said configuring circuitry for calculating one ofsaid intermediate tangent values for one of said ranges of remainingbits of least significance comprises configuring circuitry thatcalculates said one of said intermediate tangent values as a powerseries.
 20. The method of claim 15 wherein said configuring circuitryfor combining includes configuring circuitry for dividing.
 21. Themethod of claim 20 wherein said configuring circuitry for dividingcomprises configuring circuitry that performs division by approximation.22. The method of claim 21 wherein said configuring circuitry fordividing comprises configuring circuitry that performs division as apower series.
 23. The method of claim 22 wherein said configuringcircuitry for dividing comprises configuring circuitry that calculateshigher-order terms of said power series as an additive approximation.24. The method of claim 15 wherein: said configuring circuitry forcalculating a second intermediate value comprises configuring circuitryfor computing a series expansion of a tangent of a sum of bits of saidinput value of intermediate significance and bits of said input value ofleast significance.
 25. The method of claim 24 wherein said configuringcircuitry for computing a series expansion comprises: configuringcircuitry for adding said first intermediate tangent value and said bitsof said input value of least significance to provide a first interimvalue; configuring circuitry for multiplying said first intermediatetangent value and said bits of said input value of least significance toprovide a second interim value; configuring circuitry for adding saidsecond interim value to ‘1’ to provide a third interim value;configuring circuitry for multiplying said first interim value by saidthird interim value to provide a fourth interim value; configuringcircuitry for approximating a sum of ‘1’ and a square of said secondinterim value; and configuring circuitry for adding said approximatedsum to said fourth interim value.
 26. The method of claim 25 whereinsaid configuring circuitry for approximating a sum or ‘1’ and a squareof said second interim value comprises: configuring circuitry formultiplying upper bits of said second interim value by themselves toprovide an approximation of said square of said second interim value;and configuring circuitry for multiplying said approximation of saidsquare of said second interim value by said first intermediate tangentvalue.
 27. The method of claim 26 wherein: said upper bits of saidsecond interim value comprise between three bits and five bits of saidsecond interim value.
 28. The method of claim 26 wherein: saidconfiguring circuitry for adding said approximated sum to said fourthinterim value comprises configuring circuitry that adds, to said fourthinterim value, upper bits of output of said circuitry for multiplyingsaid approximation of said square of said second interim value by saidfirst intermediate tangent value.
 29. A non-transitory machine-readabledata storage medium encoded with non-transitory machine-executableinstructions for configuring a programmable integrated circuit device ascircuitry for computing a tangent function of an input value, saidinstructions comprising: instructions to configure first look-up tablecircuitry that stores pre-calculated tangent values of a limited numberof sample values; instructions to configure circuitry for inputting bitsof said input value of most significance as inputs to said first look-uptable circuitry to look up one of said pre-calculated tangent values asa first intermediate tangent value; instructions to configure circuitryfor calculating a second intermediate tangent value from one or moreranges of remaining bits of said input value; and instructions toconfigure circuitry for combining said first intermediate tangent valueand said second intermediate tangent value to yield said tangentfunction of said input value.